﻿using LinqToExcel;
using PlusAssistance.BL.Abstract;
using PlusAssistance.BL.Dtos;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace PlusAssistance.BL.Concrete
{
    public class DataImportManager : IDataImportManager
    {
        public void ImportExcelXLS(HttpPostedFileBase file, string tmpPath, string sheetName)
        {

            var filePath = Path.Combine(tmpPath, file.FileName);
            file.SaveAs(filePath);

            var excel = new ExcelQueryFactory(filePath);

            var columnNames = excel.GetColumnNames(sheetName);

            var data = from c in excel.Worksheet(sheetName) select c;

            //var data1 = (from row in excel.Worksheet(sheetName)
            //             let item = new ExcelDto
            //                 {
            //                     Gastos = row["Gastos"].Cast<string>(),
            //                     Actual = row["Actual"].Cast<int>(),
            //                     MesAnterior = row["Mes anterior"].Cast<int>()
            //                 }
            //                 select item).ToList();
        }
    }
}
